package com.education.user.controller.app;


import com.education.common.utils.ApiReturnObject;
import com.education.user.pojo.SysBanner;
import com.education.user.service.BannerService;
import com.education.user.service.SysInfoMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/app/sysbanner")
@Api(tags = {"APP--轮播图"})
public class AppBannerController {
    @Autowired
    private BannerService BannerService;

    @Autowired
    private SysInfoMsgService sysInfoMsgService;

    /**
     * 查询广告位轮播列表
     */
    @ApiOperation(value = "轮播图接口", httpMethod = "GET")
    @GetMapping("/list")
    public ApiReturnObject list(SysBanner banner,Integer userId) {
        if (banner.getSchoolId() == null){
            return new ApiReturnObject("201","参数缺失","参数缺失");
        }
        if (userId == null){
            return new ApiReturnObject("202","userId为空","userId为空");
        }else {
            List<SysBanner> sysBanners = BannerService.selectSysBannerList(banner);
            //消息总数
            Integer count = sysInfoMsgService.findCount(userId);
            return new ApiReturnObject("200","查询成功",count,sysBanners);
        }
    }


}
